process.env.NODE_ENV = 'development'
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const CleanWebpackPlugin = require('clean-webpack-plugin');

const HtmlPlugin = require('./plugins/html-plugin-comp')
const MultiHtmlPlugin = require('./plugins/multi-html-plugin')

const baseConf = require('./webpack.common')
const {
	index,
	PATHS,
	publicPath,
	cleanOptions,
} = require('./utils')

const isProduction = process.env.NODE_ENV === 'production'

const webpackConfig = merge(baseConf, {

	mode: 'development',

	devtool: 'inline-source-map',

	// module: {
	// 	rules: utils.styleLoaders({
	// 	cssSourceMap : false,
	// 		sourceMap: config.dev.cssSourceMap
	// 	})
	// },

	plugins: [
		// new CleanWebpackPlugin([path.join(PATHS.public, 'dist'), index], cleanOptions),
		new webpack.HotModuleReplacementPlugin(),
		new webpack.NamedModulesPlugin(),
		new webpack.NoEmitOnErrorsPlugin(),
		// new HtmlPlugin(),

		new MultiHtmlPlugin({
			files: path.resolve(__dirname, '../src/pages'),
			template: path.resolve(__dirname, '../src/pages/template.html'),
		}),
	],

	devServer: {
		contentBase: PATHS.public,
		compress: true,
		// index,
		// headers: {
		// 	'X-Content-Type-Options': 'nosniff',
		// 	'X-Frame-Options': 'DENY'
		// },
		open: true,
		// openPage: 'dbMonitor/static/dist/',
		// openPage: 'dist/',
		overlay: {
			warnings: true,
			errors: true
		},
		port: 8080,
		publicPath,
		// publicPath: 'http://localhost:8080/dbMonitor/static/dist/',
		hot: true,
		proxy: {
			'/cms': {
				// target: 'http://127.0.0.1:8084/'
				target: 'http://192.168.1.3:8084/'
			}
			// '/*.json': {
			// 	// target: 'http://192.168.1.3:8000/'
			// 	target: 'http://localhost:8084/'
			// }
		},
	},

})

module.exports = webpackConfig